package yecq_readwrite;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class Main {

    // 定义专门类库中的开关锁模块引入
    public static void main(String[] args) {
        ReadWriteLock rwl = new ReentrantReadWriteLock();
        for (int i = 1; i <= 5; i++) {
            new Reader("Reader-" + i, rwl.readLock()).start();
        }
        for (int i = 1; i <= 3; i++) {
            new Writer("Writer-" + i, rwl.writeLock()).start();
        }
    }
}
